package org.bigdata.platform.util;

import java.util.Iterator;

public class ArrayIterator<E> implements Iterator<E> {

	private E [] source;
	
	private int currentIndex;
	
	public ArrayIterator(E [] source) {
		if(source == null) {
			throw new NullPointerException("Source array could not be NULL");
		}
		this.source = source;
		currentIndex = 0;
	}
	
	@Override
	public boolean hasNext() {
		return currentIndex < source.length;
	}

	@Override
	public E next() {
		if(!hasNext()) {
			throw new RuntimeException("No next");
		}
		return source[currentIndex++];
	}

	@Override
	public void remove() {
		throw new RuntimeException("Unsupported Method");
	}

}
